
<{include file="www/header.tpl"}>
<{include file="www/header-base.tpl"}>

<div class="dingz">
    <h2 class="title">哇吖定制</h2>

    <div class="box fix">
        <form class="left" action="" method="post" onsubmit="return enter_submit_dingzhi();">
            <h3 class="info">哇吖定制</h3>
            <p class="prompt">您计划什么时候出行呢？想玩几天( 从国内出发至回到国内的总天数）</p>
            <div class="line">
                <span class="span">出行日期：</span>
                <select name="year" id="oYear" class="select" onblur="month_val()">
                    <option value="-1">年份</option>
                    <option value="2015">2015</option>
                    <option value="2016">2016</option>
                </select>
                <select name="month" id="oMonth" class="select" onblur="day_val()">
                    <option value="-1">月份</option>
                    <{section name=loop loop=12}>
                    <option value="<{$smarty.section.loop.index+1}>"><{$smarty.section.loop.index+1}></option>
                    <{/section}>
                </select>
                <select name="day" id="oDay" class="select">
                    <option value="-1">日期</option>
                    <option value=""></option>
                </select>
            </div>
            <p class="zhu">注：若不确定出行日期，可选择月份／日期不确定。</p>
            <div class="line" style="margin-bottom: 40px;">
                <span class="span">用户姓名：</span>
                <input type="text" name="userName" placeholder="请输入用户姓名" class="select">
                <span class="span" style="margin-left: 20px">性别：</span>
                <select id="oDay" class="select"  name="gender">
                    <option value="-1">性别</option>
                    <option value="m">男</option>
                    <option value="f">女</option>
                </select>
            </div>
            <div class="line" style="margin-bottom: 40px;">
                <span class="span">旅行天数：</span>
                <input type="text" name="dayLength" placeholder="请输入旅行天数" class="select">
                <span class="span" style="margin-left: 20px">联系电话：</span>
                <input type="text" name="mobile" placeholder="请输入联系电话" class="select">
            </div>
            <p class="zhu">补充说明我的相关需求</p>
            <textarea placeholder="在这里输入您的补充说明相关需求" name="desc"  class="textarea"></textarea>
            <{if $global_user.userUid > 0}>
            <input type="submit" value="确认提交" class="submit" onclick="return submit_dingzhi();">
            <{else}>
            <p class="tianxs">
                <a href="javascript:;" style="display: inline-block;color: #ef6b6d;margin-right: 4px" class="a" onclick="showBox($('.login-wrap'), $('.alert-bg')); $('body,html').animate({scrollTop:0},0);">登陆</a>填写定制
            </p>
            <{/if}>

        </form>
        <img src="/resource/www/imgs/dingz_img.png" class="right">
    </div>

</div>

<script>

function submit_dingzhi() {
    var oDingz = $('.dingz');
    var oYear= oDingz.find("select[name='year']").val();
    var oMonth = oDingz.find("select[name='month']").val();
    var oDay = oDingz.find("select[name='day']").val();
    var oName = oDingz.find("input[name='userName']").val();
    var oGender = oDingz.find("select[name='gender']").val();
    var oDayLength = oDingz.find("input[name='dayLength']").val();
    var oDayReg =  /^[0-9]*[1-9][0-9]*$/.test(oDayLength);
    var oMobile = oDingz.find("input[name='mobile']").val();
    if (oYear == -1) {
        layer.msg('请输入年份');
        return false;
    } else if (oMonth == -1) {
        layer.msg('请输入月份');
        return false;
    } else if (oDay == -1) {
        layer.msg('请输入日期');
        return false;
    } else if (!oName) {
        layer.msg('请输入姓名');
        return false;
    } else if (oGender == -1) {
        layer.msg('请输入性别');
        return false;
    } else if (!oDayLength || !oDayReg) {
        layer.msg('请输入旅行天数');
        return false;
    } else if (!oMobile) {
        layer.msg('请输入正确的联系电话');
        return false;
    }
}

function enter_submit_dingzhi () {
    return submit_dingzhi();
}

</script>

<script>

    function month_val(){
        var year = $("#oYear").val();
        var d = new Date();
        var cYear = d.getFullYear();
        var month = ''
        if(year == cYear){
            month = d.getMonth() + 1;
        }
        var html = "";
        for(var i=month;i <=12 ;i++){
            html +="<option value='"+i+"'>"+i+"</option>";
        }
        $('#oMonth').html(html);
    }

   function day_val(){
       var month = $("#oMonth").val();
       var year = $("#oYear").val();
       var d = new Date();
       var day = 1;
       var start = 1;
       if((month == d.getMonth() + 1) && (year == d.getFullYear()) ){
           start = d.getDate();
       }
       if(month == 2){
            day = 28;
       }else if(month == 1 || month ==3 || month == 5
               || month == 7 || month == 8 || month == 10 || month == 12){
            day = 31;
       }else{
           day = 30
       }
        var html = "";
       for(var i=start;i<=day;i++){
           html += "<option value='"+i+"'>"+i+"</option>";
       }

       $("#oDay").html(html);
   }
</script>
<{include file="www/footer.tpl"}>
